package goiot.dto;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class PageQuery {
	private int pageNum = 1;
	private int pageSize = 10;
	private List<Term> condition = new ArrayList<>();
	private List<Map<?, ?>> searchAfter;
	
	public PageQuery() {
		
	}
	public PageQuery(int pageNum, int pageSize) {
		if (pageNum < 1) {
			throw new IllegalArgumentException("pageNum must > 0");
		}
		if (pageSize < 1) {
			throw new IllegalArgumentException("pageSize must > 0");
		}
		this.pageNum = pageNum;
		this.pageSize = pageSize;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public List<Term> getCondition() {
		return condition;
	}

	public void setCondition(List<Term> condition) {
		this.condition = condition;
	}

	public List<Map<?, ?>> getSearchAfter() {
		return searchAfter;
	}

	public void setSearchAfter(List<Map<?, ?>> searchAfter) {
		this.searchAfter = searchAfter;
	}

	public class Term {
		private String key;
		private Object value;
		private Oper oper;
		
		public Term(String key, Oper oper, Object value) {
			this.key = key;
			this.oper = oper;
			this.value = value;
		}

		public String getKey() {
			return key;
		}

		public void setKey(String key) {
			this.key = key;
		}

		public Object getValue() {
			return value;
		}

		public void setValue(Object value) {
			this.value = value;
		}

		public Oper getOper() {
			return oper;
		}

		public void setOper(Oper oper) {
			this.oper = oper;
		}

	}

	public enum Oper {
		IN, EQ, NEQ, GT, GTE, LT, LTE, LIKE, BTW, NOTNULL
	}
}
